<?php
    // +----------------------------------------------------------------------
    // | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ] 
    // +----------------------------------------------------------------------
    // | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
    // +----------------------------------------------------------------------
    // | SiteUrl: http://www.luckyhhy.cn
    // +----------------------------------------------------------------------
    // | Author: LuckyHhy <jackhhy520@qq.com>
    // +----------------------------------------------------------------------
    // | Date: 2020/3/12-15:05
    // +----------------------------------------------------------------------
    // | Description:  
    // +----------------------------------------------------------------------


    namespace app\wechat\controller;


    use app\wechat\service\MediaService;
    use think\Db;

    class Review extends ChatBase
    {

        /**
         * @param int $id
         * @throws \think\db\exception\DataNotFoundException
         * @throws \think\db\exception\ModelNotFoundException
         * @throws \think\exception\DbException
         * @author: LuckyHhy <jackhhy520@qq.com>
         * @date: 2020/3/12
         * @name: news
         * @describe:图文信息
         */
        public function news($id = 0)
        {
            $this->id   = empty($id) ? input('id') : $id;
            $this->news = MediaService::news($this->id);

            return $this->fetch();
        }

        /**
         * @param int $id
         * @throws \think\Exception
         * @throws \think\db\exception\DataNotFoundException
         * @throws \think\db\exception\ModelNotFoundException
         * @throws \think\exception\DbException
         * @throws \think\exception\PDOException
         * @author: LuckyHhy <jackhhy520@qq.com>
         * @date: 2020/3/12
         * @name: view
         * @describe:文章展示
         */
        public function view($id = 0)
        {
            $where = ['id' => empty($id) ? input('id') : $id];

            Db::name('WechatNewsArticle')->where($where)->update(['read_num' => Db::raw('read_num+1')]);

            $this->info = Db::name('WechatNewsArticle')->where($where)->find();

            return $this->fetch();
        }

        /**
         * @author: LuckyHhy <jackhhy520@qq.com>
         * @date: 2020/3/12
         * @name: text
         * @describe:文本展示
         */
        public function text()
        {
            $this->content = strip_tags(input('content', ''), '<a><img>');

            return $this->fetch();
        }

        /**
         * @author: LuckyHhy <jackhhy520@qq.com>
         * @date: 2020/3/12
         * @name: image
         * @describe:图片展示
         */
        public function image()
        {
            $this->content = strip_tags(input('content', ''), '<a><img>');

            return $this->fetch();
        }

        /**
         * @author: LuckyHhy <jackhhy520@qq.com>
         * @date: 2020/3/12
         * @name: video
         * @describe:视频展示
         */
        public function video()
        {
            $this->url   = strip_tags(input('url', ''), '<a><img>');
            $this->title = strip_tags(input('title', ''), '<a><img>');

            return $this->fetch();
        }

        /**
         * @author: LuckyHhy <jackhhy520@qq.com>
         * @date: 2020/3/12
         * @name: voice
         * @describe:语音展示
         */
        public function voice()
        {
            $this->url = strip_tags(input('url', ''), '<a><img>');

            return $this->fetch();
        }

        /**
         * @author: LuckyHhy <jackhhy520@qq.com>
         * @date: 2020/3/12
         * @name: music
         * @describe:音乐展示
         */
        public function music()
        {
            $this->url   = strip_tags(input('url', ''), '<a><img>');
            $this->desc  = strip_tags(input('desc', ''), '<a><img>');
            $this->title = strip_tags(input('title', ''), '<a><img>');

            return $this->fetch();
        }

    }